package core

import (
	"github/kadycui/gids/middleware"
	"github/kadycui/gids/pkg/rmq"
	"strconv"
	"time"

	"github.com/gin-gonic/gin"
)

func Ping(ctx *gin.Context) {
	middleware.Log.Info("这是Ping !!!")

	// 获取当前时间
	currentTime := time.Now()

	rmq := rmq.NewRabbitMQPubSub("" + "game_queue")
	for i := 0; i < 10000; i++ {
		rmq.PublishPub("订阅模式生产第" + strconv.Itoa(i) + "条" + "数据")
		// fmt.Println("订阅模式生产第" + strconv.Itoa(i) + "条" + "数据")
		time.Sleep(1 * time.Second)
	}

	// 格式化时间为字符串
	timeString := currentTime.Format("2006-01-02 15:04:05")

	ctx.JSON(200, gin.H{
		"code": 0,
		"msg":  "pong",
		"time": timeString,
	})
}
